**********************************
* Comparing the Impact of Forced Switch to 
* Digital Payments on Offline and Online Purchases
* (Table 11)
**********************************

cap log close _all
log using ../logs/regression_tables.txt, append text nomsg name(log2)

log off log2

eststo clear
estimates clear

** results 1: online grocery sample
use ${datafolder}/online_cid_yearmonth_did_sample_real_INR.dta, clear
merge m:1 cid using ${datafolder}\online_matched_cid, assert(master match) keep(match) nogenerate

eststo reg_noncash_online: reghdfe noncash_amt_pct after_cash_amt_pct_before if yearmonth <= ym(2017,9), ///
	absorb(cid DTCode##yearmonth) vce(cluster cid  yearmonth) nosample noconstant
	
eststo reg_loglevel_online: reghdfe ltender_amt_month after_cash_amt_pct_before if yearmonth <= ym(2017,9), ///
	absorb(cid DTCode##yearmonth) vce(cluster cid  yearmonth) nosample noconstant

	
** results 2: supermarket matched sample
use ${datafolder}/supermarket_cid_yearmonth_did_sample_real_INR.dta, clear
merge m:1 cid using ${datafolder}\supermarket_matched_cid, assert(master match) keep(match) nogenerate

eststo reg_noncash_supermkt: quietly reghdfe noncash_amt_pct after_cash_amt_pct_before, absorb(cid DTCode##yearmonth) vce(cluster cid  yearmonth) nosample noconstant

eststo reg_ltender_supermkt: quietly reghdfe ltender_amt_month after_cash_amt_pct_before, absorb(cid DTCode##yearmonth) vce(cluster cid  yearmonth) nosample noconstant

** Format the table
log on log2
display "Table 11"
#delimit ;
estfe reg_*_online reg_*_supermkt,
	labels(cid "Individual FEs" yearmonth "Year-Month FEs" DTCode#yearmonth "District * Year-Month FEs");
esttab reg_noncash_online reg_loglevel_online
	reg_noncash_supermkt reg_ltender_supermkt, b(%8.3f) varwidth(25) brackets noconstant 
	stats(r2 N_full, fmt(a %15.0fc) 
		labels("R2" "No. of Observations")) 
	label  noomitted 
	indicate(`r(indicate_fe)')  
	nomtitles	numbers 
	varlabels(after_cash_amt_pct_before "PriorCashDependence * Post") 
	;
estfe reg_*_online reg_*_supermkt, restore;
#delimit cr
log off log2
